package com.opNaga.bpmp;

import java.util.Random;

/**
 * User: Junyi BEI
 * Date: 19/01/2012
 * Time: 01:04
 */
public abstract class BPMPElement {
  protected Random random;
  protected String name;
  protected String text;
  protected BPMPManager manager;
  protected boolean mute;

  public BPMPElement() {
    int ri = getRandom().nextInt(1000);
    name = getInitial() + Integer.toString(ri) + "TEST@" + Long.toString(System.currentTimeMillis());
  }

  public BPMPElement(String n) {
    name = n;
  }

  @Override
  public String toString() {
    return getType() + " " + name;
  }

  public Random getRandom() {
    if(random == null) {
      random = new Random();
    }
    return random;
  }

  public String getInitial() {
    String t = getType();
    String[] s = t.split(" ");
    String r = "";
    int l = s.length;
    for(int i = 0; i < l; i++) {
      if(!s[i].isEmpty()) {
        char c = s[i].charAt(0);
        if(Character.isLetter(c)) {
          char lc = Character.toLowerCase(c);
          r += lc;
        }
      }
    }
    return r;
  }

  public boolean destroy() {
    if(manager != null) {
      if(!manager.removeInstance(this)) {
        return false;
      }
    }
    return standardMessage(890);
  }

  public BPMPElement mute() {
    mute = true;
    return this;
  }

  public boolean setName(String n) {
    if(manager != null) {
      if(!manager.renameInstance(this, n)) {
        return false;
      }
    }
    name = n;
    return true;
  }

  public String getName() {
    return name;
  }

  public boolean setText(String t) {
    text = t;
    return true;
  }

  public String getText() {
    return text;
  }

  public boolean setFactory(BPMPManager bf) {
    if(manager != null) {
      return false;
    }
    manager = bf;
    return true;
  }

  public BPMPManager getManager() {
    return manager;
  }

  public boolean standardMessage(int c, Object... t) {
    /* message level (l)
     *  0:  notification
     *  3:  operation succeeded
     *  5:  warning, operation partially succeeded
     *  9:  normal error, operation aborted, recovered to state before operation
     *  10: fatal error, operation aborted, unable to recover
     */

    int l = 9;
    String p = "[" + c + "] ";
    boolean r = false;
    switch(c) {
      case 0: //
        p += t[0] + " has not been added to " + this;
        l = 5;
        r = true;
        break;
      // 100 - 199: adding a connecting object
      // // 100 - 109: failed adding an outward sequence flow
      case 100: // type
        p += "Cannot add " + t[0] + " as an outward Sequence Flow to " + this + " because " + t[0] + " is not a Sequence Flow element";
        break;
      case 101: // already exists
        p += "Cannot add " + t[0] + " as an outward Sequence Flow to " + this + " because " + this + " already contains " + t[0] + " as an outward Sequence Flow";
        break;
      // // 110 - 119: failed adding an outward message flow
      case 110: // type
        p += "Cannot add " + t[0] + " as an outward Message Flow to " + this + " because " + t[0] + " is not a Message Flow element";
        break;
      case 111: // already exists
        p += "Cannot add " + t[0] + " as an outward Message Flow to " + this + " because " + this + " already contains " + t[0] + " as an outward Message Flow";
        break;
      // // 120 - 129: failed adding an outward association flow
      case 120: //  type
        p += "Cannot add " + t[0] + " as an outward Association Flow to " + this + " because " + t[0] + " is not an Association element";
        break;
      case 121: // already exists
        p += "Cannot add " + t[0] + " as an outward Association Flow to " + this + " because " + this + " already contains " + t[0] + " as an outward Association";
        break;
      // // 130 - 139: failed adding an inward sequence flow
      case 130: // type
        p += "Cannot add " + t[0] + " as an inward Sequence Flow to " + this + " because " + t[0] + " is not a Sequence Flow element";
        break;
      case 131: // already exists
        p += "Cannot add " + t[0] + " as an inward Sequence Flow to " + this + " because " + this + " already contains " + t[0] + " as an inward Sequence Flow";
        break;
      // // 140 - 149: failed adding an inward message flow
      case 140: // type
        p += "Cannot add " + t[0] + " as an inward Message Flow to " + this + " because " + t[0] + " is not a Message Flow element";
        break;
      case 141: // already exists
        p += "Cannot add " + t[0] + " as an inward Message Flow to " + this + " because " + this + " already contains " + t[0] + " as an inward Message Flow";
        break;
      // // 150 - 159: failed adding an inward association flow
      case 150: // type
        p += "Cannot add " + t[0] + " as an inward Association Flow to " + this + " because " + t[0] + " is not an Association Flow element";
        break;
      case 151: // already exists
        p += "Cannot add " + t[0] + " as an inward Association Flow to " + this + " because " + this + " already contains " + t[0] + " as an inward Association Flow";
        break;
      // // 190 - 199: succeeded adding an connecting object
      case 190: // outward sequence flow
        p += "Successfully added " + t[0] + " as an outward Sequence Flow to " + this;
        l = 3;
        r = true;
        break;
      case 191: // outward message flow
        p += "Successfully added " + t[0] + " as an outward Message Flow to " + this;
        l = 3;
        r = true;
        break;
      case 192: // outward association flow
        p += "Successfully added " + t[0] + " as an outward Association Flow to " + this;
        l = 3;
        r = true;
        break;
      case 193: // inward sequence flow
        p += "Successfully added " + t[0] + " as an inward Sequence Flow to " + this;
        l = 3;
        r = true;
        break;
      case 194: // inward message flow
        p += "Successfully added " + t[0] + " as an inward Message Flow to " + this;
        l = 3;
        r = true;
        break;
      case 195: // inward association flow
        p += "Successfully added " + t[0] + " as an inward Association Flow to " + this;
        l = 3;
        r = true;
        break;

      // 200 - 299: removing a connecting object
      // // 200 - 209: failed removing an outward sequence flow
      case 200: // type
        p += "Cannot remove " + t[0] + " as an outward Sequence Flow from " + this + " because " + t[0] + " is not a Sequence Flow element";
        break;
      case 201: // does not exist
        p += "Cannot remove " + t[0] + " as an outward Sequence Flow from " + this + " because " + this + " does not contain " + t[0] + " as an outward Sequence Flow";
        break;
      // // 210 - 219: failed removing an outward message flow
      case 210: // type
        p += "Cannot remove " + t[0] + " as an outward Message Flow from " + this + " because " + t[0] + " is not a Message Flow element";
        break;
      case 211: // does not exist
        p += "Cannot remove " + t[0] + " as an outward Message Flow from " + this + " because " + this + " does not contain " + t[0] + " as an outward Message Flow";
        break;
      // // 220 - 229: failed removing an outward association flow
      case 220: // type
        p += "Cannot remove " + t[0] + " as an outward Association Flow from " + this + " because " + t[0] + " is not an Association Flow element";
        break;
      case 221: // does not exist
        p += "Cannot remove " + t[0] + " as an outward Association Flow from " + this + " because " + this + " does not contain " + t[0] + " as an outward Association Flow";
        break;
      // // 230 - 239: failed removing an inward sequence flow
      case 230: // type
        p += "Cannot remove " + t[0] + " as an inward Sequence Flow from " + this + " because " + t[0] + " is not a Sequence Flow element";
        break;
      case 231: // does not exist
        p += "Cannot remove " + t[0] + " as an inward Sequence Flow from " + this + " because " + this + " does not contain " + t[0] + " as an inward Sequence Flow";
        break;
      // // 240 - 249: failed removing an inward message flow
      case 240: // type
        p += "Cannot remove " + t[0] + " as an inward Message Flow from " + this + " because " + t[0] + " is not a Message Flow element";
        break;
      case 241: // does not exist
        p += "Cannot remove " + t[0] + " as an inward Message Flow from " + this + " because " + this + " does not contain " + t[0] + " as an inward Message Flow";
        break;
      // // 250 - 259: failed removing an inward association flow
      case 250: // type
        p += "Cannot remove " + t[0] + " as an inward Association Flow from " + this + " because " + t[0] + " is not an Association Flow element";
        break;
      case 251: // does not exist
        p += "Cannot remove " + t[0] + " as an inward Association Flow from " + this + " because " + this + " does not contain " + t[0] + " as an inward Association Flow";
        break;
      // // 290 - 299: succeeded removing a connecting object
      case 290: // outward sequence flow
        p += "Successfully removed " + t[0] + " as an outward Sequence Flow from " + this;
        l = 3;
        r = true;
        break;
      case 291: // outward message flow
        p += "Successfully removed " + t[0] + " as an outward Message Flow from " + this;
        l = 3;
        r = true;
        break;
      case 292: // outward association flow
        p += "Successfully removed " + t[0] + " as an outward Association Flow from " + this;
        l = 3;
        r = true;
        break;
      case 293: // inward sequence flow
        p += "Successfully removed " + t[0] + " as an inward Sequence Flow from " + this;
        l = 3;
        r = true;
        break;
      case 294: // inward message flow
        p += "Successfully removed " + t[0] + " as an inward Message Flow from " + this;
        l = 3;
        r = true;
        break;
      case 295: // inward association flow
        p += "Successfully removed " + t[0] + " as an inward Association Flow from " + this;
        l = 3;
        r = true;
        break;

      // 300 - 399: setting connecting object
      // // 300 - 309: failed setting connecting object target 
      case 300: // already has target
        p += "Cannot set the target of " + this + " to " + t[0] + " because " + this + " already has target " + t[1];
        break;
      case 301: // invalid
        p += "Cannot set the target of " + this + " to " + t[0] + " because " + t[0] + " cannot be validated";
        break;
      // // 310 - 319: failed setting connecting object source
      case 310: // already has source
        p += "Cannot set the source of " + this + " to " + t[0] + " because " + this + " already has source " + t[1];
        break;
      case 311: // invalid
        p += "Cannot set the source of " + this + " to " + t[0] + " because " + t[0] + " cannot be validated";
        break;
      // // 350 - 359: failed validate target
      case 350: // type
        p += "Cannot validate " + t[0] + " as a target because " + t[0] + " is of an unacceptable type";
        break;
      case 351: // no root
        p += "Cannot validate " + t[0] + " as a target because " + t[0] + " does not have a root";
        break;
      case 352: // source has a different root
        p += "Cannot validate " + t[0] + " as a target because " + t[0] + " and " + t[1] + " have different roots ";
        break;
      case 353: // source have the same root
        p += "Cannot validate " + t[0] + " as a target because " + t[0] + " and " + t[1] + " the same root ";
        break;
      case 354: // failed adding
        p += "Cannot validate " + t[0] + " as a target because " + t[0] + " cannot accept " + this;
        break;
      // // 360 - 369: failed validate source
      case 360: // type
        p += "Cannot validate " + t[0] + " as a source because " + t[0] + " is of an unacceptable type";
        break;
      case 361: // no root
        p += "Cannot validate " + t[0] + " as a source because " + t[0] + " does not have a root";
        break;
      case 362: // target has a different root
        p += "Cannot validate " + t[0] + " as a source because " + t[0] + " and " + t[1] + " have different roots ";
        break;
      case 363: // target have the same root
        p += "Cannot validate " + t[0] + " as a source because " + t[0] + " and " + t[1] + " the same root ";
        break;
      case 364: // failed adding
        p += "Cannot validate " + t[0] + " as a source because " + t[0] + " cannot accept" + this;
        break;
      // // 390 - 399: succeeded setting connecting object
      case 390: // target set
        p += "Successfully set " + this + "'s target to " + t[0];
        l = 3;
        r = true;
        break;
      case 391: // source set
        p += "Successfully set " + this + "'s source to " + t[0];
        l = 3;
        r = true;
        break;
      case 392: // target validated 
        p += "Successfully validated " + t[0] + " as " + this + "'s target";
        l = 3;
        r = true;
        break;
      case 393: // source validated
        p += "Successfully validated " + t[0] + " as " + this + "'s source";
        l = 3;
        r = true;
        break;
      case 394: // target reset
        p += "Successfully reset " + this + "'s target";
        l = 3;
        r = true;
        break;
      case 395: // source reset
        p += "Successfully reset " + this + "'s source";
        l = 3;
        r = true;
        break;

      // 400 - 499: element registration
      // // 400 - 409: failed register start event
      case 400: // type
        p += "Cannot register " + t[0] + " as a Start Event in " + this + " because " + t[0] + " is not a Start Event element";
        break;
      case 401: // already registered
        p += "Cannot register " + t[0] + " as a Start Event in " + this + " because " + t[0] + " is already registered as a Start Event in " + this;
        break;
      // // 410 - 419: failed deregister start event
      case 410: // type
        p += "Cannot deregister " + t[0] + " as a Start Event in " + this + " because " + t[0] + " is not a Start Event element";
        break;
      case 411: // not registered
        p += "Cannot deregister " + t[0] + " as a Start Event in " + this + " because " + t[0] + " is not registered as a Start Event in " + this;
        break;
      // // 420 - 429: failed register end event
      case 420: // type
        p += "Cannot register " + t[0] + " as an End Event in " + this + " because " + t[0] + " is not an End Event element";
        break;
      case 421: // already registered
        p += "Cannot register " + t[0] + " as an End Event in " + this + " because " + t[0] + " is already registered as an End Event in " + this;
        break;
      // // 430 - 439: failed deregister end event
      case 430: // type
        p += "Cannot deregister " + t[0] + " as an End Event in " + this + " because " + t[0] + " is not an End Event element";
        break;
      case 431: // not registered
        p += "Cannot deregister " + t[0] + " as an End Event in " + this + " because " + t[0] + " is not registered as an End Event in " + this;
        break;
      // // 490 - 499: operation successful
      case 490: // register start
        p += "Successfully registered " + t[0] + " as a Start Event in " + this;
        l = 3;
        r = true;
        break;
      case 491: // deregister start
        p += "Successfully registered " + t[0] + " as a Start Event in " + this;
        l = 3;
        r = true;
        break;
      case 492: // register end
        p += "Successfully registered " + t[0] + " as a End Event in " + this;
        l = 3;
        r = true;
        break;
      case 493: // deregister end
        p += "Successfully registered " + t[0] + " as a End Event in " + this;
        l = 3;
        r = true;
        break;

      // 500 - 549: lane and pool
      // // 500 - 509: failed adding lane
      case 500: // type
        p += "Cannot add " + t[0] + " as a child Lane to " + this + " because " + t[0] + " is not a Lane element";
        break;
      case 501: // single lane
        p += "Cannot add " + t[0] + " as a child Lane to " + this + " because " + this + "(single-lane Pool) already contains non-Lane element(s)";
        break;
      case 502: // cannot set parent
        p += "Cannot add " + t[0] + " as a child Lane to " + this + " because " + t[0] + " cannot set its parent Pool to " + this;
        break;
      case 503: // already contains
        p += "Cannot add " + t[0] + " as a child Lane to " + this + " because " + this + " already contains " + t[0] + " as a Lane element";
        break;
      // // 510 - 519: failed removing lane
      case 510: // type
        p += "Cannot remove " + t[0] + " as a child Lane from " + this + " because " + t[0] + " is not a Lane element";
        break;
      case 511: // cannot reset parent
        p += "Cannot remove " + t[0] + " as a child Lane from " + this + " because " + t[0] + "'s parent Pool cannot be reset";
        break;
      case 512: // does not contain
        p += "Cannot remove " + t[0] + " as a child Lane from " + this + " because " + this + " does not contain " + t[0] + " as a Lane element";
        break;
      // // 520 - 529: failed setting parent
      case 520: // type
        p += "Cannot set the parent Pool of " + this + " to " + t[0] + " because " + t[0] + " is not a Pool element";
        break;
      case 521: // already has parent
        p += "Cannot set the parent Pool of " + this + " to " + t[0] + " because " + this + " already has parent Pool " + t[1];
        break;
      // // 540 - 549: operation successful
      case 540: // adding
        p += "Successfully added " + t[0] + " as a child Lane in " + this;
        l = 3;
        r = true;
        break;
      case 541: // removing
        p += "Successfully remove " + t[0] + " as a child Lane in " + this;
        l = 3;
        r = true;
        break;
      case 542: // setting parent pool
        p += "Successfully set " + this + "'s parent Pool to " + t[0];
        l = 3;
        r = true;
        break;

      // 550 - 599: containable and container
      // // 550 - 559: failed adding containable
      case 550: // type
        p += "Cannot add " + t[0] + " as a Containable to " + this + " because " + t[0] + " is not a Containable element";
        break;
      case 551: // cannot set container
        p += "Cannot add " + t[0] + " as a Containable to " + this + " because " + t[0] + " cannot set its Container to " + this;
        break;
      case 552: // already contains
        p += "Cannot add " + t[0] + " as a Containable to " + this + " because " + this + " already contains " + t[0] + " as a Containable element";
        break;
      case 553: // cannot register start event
        p += "Cannot add " + t[0] + " as a Containable to " + this + " because " + t[0] + " cannot be registered as a Start Event";
        break;
      case 554: // cannot register end event
        p += "Cannot add " + t[0] + " as a Containable to " + this + " because " + t[0] + " cannot be registered as an End Event";
        break;
      case 555: // multiple lane
        p += "Cannot add " + t[0] + " as a Containable to " + this + " because " + this + "(multiple-lane) already contains Lane element(s)";
        break;
      // // 560 - 569: failed removing containable
      case 560: // type
        p += "Cannot remove " + t[0] + " as a Containable from " + this + " because " + t[0] + " is not a Containable element";
        break;
      case 561: // cannot reset container
        p += "Cannot remove " + t[0] + " as a Containable from " + this + " because " + t[0] + "'s Container cannot be reset";
        break;
      case 562: // does not contain
        p += "Cannot remove " + t[0] + " as a Containable from " + this + " because " + this + " does not contain " + t[0] + " as a Containable element";
        break;
      case 563: // cannot deregister start event
        p += "Cannot remove " + t[0] + " as a Containable from " + this + " because " + t[0] + " cannot be deregistered as a Start Event";
        break;
      case 564: // cannot deregister end event
        p += "Cannot remove " + t[0] + " as a Containable from " + this + " because " + t[0] + " cannot be deregistered as an End Event";
        break;
      // // 570 - 579: failed setting container
      case 570: // type
        p += "Cannot set the Container of " + this + " to " + t[0] + " because " + t[0] + " is not a Container element";
        break;
      case 571: // already has container
        p += "Cannot set the Container of " + this + " to " + t[0] + " because " + this + " already has Container " + t[1];
        break;
      case 572: // containable's type
        p += "Cannot set the Container of " + this + " to " + t[0] + " because " + this + " contains " + t[1] + " which is not a valid Containable element";
        break;
      case 573: // cannot set containable's root
        p += "Cannot set the Container of " + this + " to " + t[0] + " because " + this + " contains " + t[1] + " whose root cannot be modified";
        break;
      // // 590 - 599: operation successful
      case 590: // adding
        p += "Successfully added " + t[0] + " as a Containable to " + this;
        l = 3;
        r = true;
        break;
      case 591: // removing
        p += "Successfully removed " + t[0] + " as a Containable to " + this;
        l = 3;
        r = true;
        break;
      case 592: // setting container
        p += "Successfully set " + this + "'s Container to " + t[0];
        l = 3;
        r = true;
        break;

      // 600 - 649: portal and portal entry
      // // 600 - 609: failed adding portal
      case 600: // type
        p += "Cannot add " + t[0] + " as a Portal to " + this + " because " + t[0] + " is not a Portal element";
        break;
      case 601: // cannot set portal entry
        p += "Cannot add " + t[0] + " as a Portal to " + this + " because " + t[0] + " cannot set its Portal Entry to " + this;
        break;
      case 602: // already contains
        p += "Cannot add " + t[0] + " as a Portal to " + this + " because " + this + " already contains " + t[0] + " as a Portal";
        break;
      // // 610 - 619: failed removing portal
      case 610: // type
        p += "Cannot remove " + t[0] + " as a Portal from " + this + " because " + t[0] + " is not a Portal element";
        break;
      case 611: // cannot reset portal entry
        p += "Cannot remove " + t[0] + " as a Portal from " + this + " because " + t[0] + "'s Portal Entry cannot be reset";
        break;
      case 612: // does not contain
        p += "Cannot remove " + t[0] + " as a Portal from " + this + " because " + this + " does not contain " + t[0] + " as a Portal element";
        break;
      // // 620 - 629: failed setting portal entry
      case 620: // type
        p += "Cannot set the Portal Entry of " + this + " to " + t[0] + " because " + t[0] + " is not a Portal Entry element";
        break;
      case 621: // already has portal entry
        p += "Cannot set the Portal Entry of " + this + " to " + t[0] + " because " + this + " already has Portal Entry " + t[1];
        break;
      // // 640 - 649: operation successful
      case 640: // adding
        p += "Successfully added " + t[0] + " as a Portal to " + this;
        l = 3;
        r = true;
        break;
      case 641: // removing
        p += "Successfully removed " + t[0] + " as a Portal to " + this;
        l = 3;
        r = true;
        break;
      case 642: // setting portal entry
        p += "Successfully set " + this + "'s Portal Entry to " + t[0];
        l = 3;
        r = true;
        break;

      // 650 - 699: groupable and grouper
      // // 650 - 659: failed adding groupable
      case 650: // type
        p += "Cannot add " + t[0] + " as a Groupable to " + this + " because " + t[0] + " is not a Groupable element";
        break;
      case 651: // cannot add grouper
        p += "Cannot add " + t[0] + " as a Groupable to " + this + " because " + t[0] + " cannot add " + this + " as a Grouper";
        break;
      case 652: // already contains
        p += "Cannot add " + t[0] + " as a Groupable to " + this + " because " + this + " already contains " + t[0] + " as a Groupable element";
        break;
      // // 660 - 669: failed removing groupable
      case 660: // type
        p += "Cannot remove " + t[0] + " as a Groupable from " + this + " because " + t[0] + " is not a Groupable element";
        break;
      case 661: // cannot remove grouper
        p += "Cannot remove " + t[0] + " as a Groupable from " + this + " because " + t[0] + " cannot removed " + this + " as a Grouper";
        break;
      case 662: // does not contain
        p += "Cannot remove " + t[0] + " as a Groupable from " + this + " because " + this + " does not contain " + t[0] + " as a Groupable element";
        break;
      // // 670 - 679: failed adding grouper
      case 670: // type
        p += "Cannot add " + t[0] + " as a Grouper of " + this + " because " + t[0] + " is not a Grouper element";
        break;
      case 671: // already grouped
        p += "Cannot add " + t[0] + " as a Grouper of " + this + " because " + this + " has already been Grouped by " + t[0];
        break;
      // // 680 - 689: failed removing grouper
      case 680: //type
        p += "Cannot remove " + t[0] + " as a Grouper from " + this + " because " + t[0] + " is not a Grouper element";
        break;
      case 681: // not grouped
        p += "Cannot remove " + t[0] + " as a Grouper from " + this + " because " + this + " is not grouped by " + t[0];
        break;
      // // 690 - 699: operation successful
      case 690: // adding groupable
        p += "Successfully added " + t[0] + " as a Groupable to " + this;
        l = 3;
        r = true;
        break;
      case 691: // removing groupable
        p += "Successfully removed " + t[0] + " as a Groupable to " + this;
        l = 3;
        r = true;
        break;
      case 692: // adding grouper
        p += "Successfully added " + t[0] + " as a Grouper to " + this;
        l = 3;
        r = true;
        break;
      case 693: // removing grouper
        p += "Successfully removed " + t[0] + " as a Grouper to " + this;
        l = 3;
        r = true;
        break;

      // 700 - 749: root
      // // 700 - 709: failed setting root
      case 700:
        p += "Cannot set the root of " + this + " to " + t[0] + " because " + this + " contains " + t[1] + " which has no root";
        break;
      case 701:
        p += "Cannot set the root of " + this + " to " + t[0] + " because " + this + " contains " + t[1] + " whose root cannot be modified";
        break;
      case 702:
        p += "Cannot set the root of " + this + " to " + t[0] + " because " + this + " includes " + t[1] + " which has no root";
        break;
      case 703:
        p += "Cannot set the root of " + this + " to " + t[0] + " because " + this + " includes " + t[1] + " whose root cannot be modified";
        break;
      // // 740 - 749: succeeded setting root
      case 740:
        p += "Successfully set the root of " + this + " to " + t[0];
        l = 3;
        r = true;
        break;

      // 750 - 799: requirements
      // // 750 - 759: ability requirement
      case 750: // type
        p += "Cannot add " + t[0] + " as an Ability Requirement to " + this + " because " + t[0] + " is not an Ability";
        break;
      case 751: // already has
        p += "Cannot add " + t[0] + " as an Ability Requirement to " + this + " because " + this + " already has " + t[0] + " as an Ability Requirement";
        break;
      case 752: // type
        p += "Cannot remove " + t[0] + " as an Ability Requirement from " + this + " because " + t[0] + " is not an Ability";
        break;
      case 753: // does not have
        p += "Cannot remove " + t[0] + " as an Ability Requirement from " + this + " because " + this + " does not have " + t[0] + " as an Ability Requirement";
        break;
      case 758:
        p += "Successfully add " + t[0] + " as an Ability Requirement to " + this;
        l = 3;
        r = true;
        break;
      case 759:
        p += "Successfully remove " + t[0] + " as an Ability Requirement from " + this;
        l = 3;
        r = true;
        break;
      // // 760 - 769: position requirement
      case 760: // type
        p += "Cannot add " + t[0] + " as a Position Requirement to " + this + " because " + t[0] + " is not a Position";
        break;
      case 761: // already has
        p += "Cannot add " + t[0] + " as a Position Requirement to " + this + " because " + this + " already has " + t[0] + " as a Position Requirement";
        break;
      case 762: // type
        p += "Cannot remove " + t[0] + " as a Position Requirement from " + this + " because " + t[0] + " is not a Position";
        break;
      case 763: // does not have
        p += "Cannot remove " + t[0] + " as a Position Requirement from " + this + " because " + this + " does not have " + t[0] + " as a Position Requirement";
        break;
      case 768:
        p += "Successfully add " + t[0] + " as a Position Requirement to " + this;
        l = 3;
        r = true;
        break;
      case 769:
        p += "Successfully remove " + t[0] + " as a Position Requirement from " + this;
        l = 3;
        r = true;
        break;
      // // 770 - 779: network requirement
      case 770: // type
        p += "Cannot add " + t[0] + " as a Network Requirement to " + this + " because " + t[0] + " is not a Network";
        break;
      case 771: // already has
        p += "Cannot add " + t[0] + " as a Network Requirement to " + this + " because " + this + " already has " + t[0] + " as a Network Requirement";
        break;
      case 772: // type
        p += "Cannot remove " + t[0] + " as a Network Requirement from " + this + " because " + t[0] + " is not a Network";
        break;
      case 773: // does not have
        p += "Cannot remove " + t[0] + " as a Network Requirement from " + this + " because " + this + " does not have " + t[0] + " as a Network Requirement";
        break;
      case 778:
        p += "Successfully add " + t[0] + " as a Network Requirement to " + this;
        l = 3;
        r = true;
        break;
      case 779:
        p += "Successfully remove " + t[0] + " as a Network Requirement from " + this;
        l = 3;
        r = true;
        break;
      // // 780 - 789: requirement tree
      case 780: // type
        p += "Cannot add " + t[0] + " as a preceded Requirement to " + this + " because " + t[0] + " and " + this + " are of different types";
        break;
      case 781:
        p += "Cannot add " + t[0] + " as a preceded Requirement to " + this + " because " + t[0] + " succeeds " + this;
        break;
      case 782: // already has
        p += "Cannot add " + t[0] + " as a preceded Requirement to " + this + " because " + this + " already has " + t[0] + " as a preceded Requirement";
        break;
      case 783: // type
        p += "Cannot remove " + t[0] + " as a preceded Requirement from " + this + " because " + t[0] + " and " + this + " are of different types";
        break;
      case 784: // does not have
        p += "Cannot remove " + t[0] + " as a preceded Requirement from " + this + " because " + this + " does not have " + t[0] + " as a preceded Requirement";
        break;
      case 788:
        p += "Successfully add " + t[0] + " as a preceded Requirement to " + this;
        l = 3;
        r = true;
        break;
      case 789:
        p += "Successfully remove " + t[0] + " as a preceded Requirement from " + this;
        l = 3;
        r = true;
        break;
      

      // 800 - 899: destroying object
      // // 800 - 809: failed destroying connective object
      case 800: // outward connecting object failed to be destroyed
        p += "Cannot destroy " + this + " because outward " + t[0] + " cannot be destroyed";
        break;
      case 801: // inward connecting object failed to be destroyed
        p += "Cannot destroy " + this + " because inward " + t[0] + " cannot be destroyed";
        break;
      // // 810 - 819: failed destroying connecting object
      case 810: // outward  connection failed to be removed
        p += "Cannot destroy " + this + " because outward " + this + " cannot be removed from " + t[0];
        break;
      case 811: // inward  connection failed to be removed
        p += "Cannot destroy " + this + " because inward " + this + " cannot be removed from " + t[0];
        break;
      // // 820 - 829: failed destroying container
      case 820: // contained element failed to be destroyed
        p += "Cannot destroy " + this + " because Containable" + t[0] + " cannot be destroyed";
        break;
      // // 830 - 839: failed destroying containable
      case 830: // ailed to be removed from container
        p += "Cannot destroy " + this + " because " + this + " cannot be removed from its Container " + t[0];
        break;
      // // 840 - 849: failed destroying pool
      case 840: // child lane failed to be destroyed
        p += "Cannot destroy " + this + " because Lane " + t[0] + " cannot be destroyed";
        break;
      // // 850 - 859: failed destroying lane
      case 850: // failed to be removed from parent pool
        p += "Cannot destroy " + this + " because Lane " + this + " cannot be removed from its parent Pool " + t[0];
        break;
      // // 860 - 869: failed destroying attachable object
      case 860: // attachment failed to be destroyed
        p += "Cannot destroy " + this + " because attached element " + t[0] + " cannot be destroyed";
        break;
      // // 890 - 899: succeeded destroying object
      case 890: //
        p += this + " has been successfully destroyed";
        l = 3;
        r = true;
        break;

      // 900 - 999 : multi-functional operation
      // // 900 - 919: link to connective object via a new connecting object
      // // //900 - 909: failed linking to target connective object
      case 900:
        p += "Cannot link to " + t[0] + " from " + this + " because " + t[1] + "'s target cannot be set to " + t[0];
        break;
      case 901:
        p += "Cannot link to " + t[0] + " from " + this + " because " + t[1] + "'s source cannot be set to " + this;
        break;
      case 902:
        p += "Cannot link to " + t[0] + " from " + this + " because " + t[0] + " is registered with a different manager";
        break;
      case 903:
        p += "Cannot link to " + t[0] + " from " + this + " because a connecting object cannot be created from manager";
        break;
      case 904:
        p += "Cannot link to " + t[0] + " from " + this + " because no connection type can be adopted for this linkage";
        break;
      // // // 910 - 919: succeeded linking to target connective object
      case 910:
        p += "Successfully linked to " + t[0] + " from " + this + " via " + t[1] + "(registered with manager)";
        l = 3;
        r = true;
        break;
      case 911:
        p += "Successfully linked to " + t[0] + " from " + this + " via " + t[1];
        l = 3;
        r = true;
        break;
      // // 920 - 939: link from connective object via a new connecting object
      // // // 920 - 929: failed linking from source connective object
      case 920:
        p += "Cannot link from " + t[0] + " to " + this + " because " + t[1] + "'s target cannot be set to " + t[0];
        break;
      case 921:
        p += "Cannot link from " + t[0] + " to " + this + " because " + t[1] + "'s source cannot be set to " + this;
        break;
      case 922:
        p += "Cannot link from " + t[0] + " to " + this + " because " + t[0] + " is registered with a different manager";
        break;
      case 923:
        p += "Cannot link from " + t[0] + " to " + this + " because a connecting object cannot be created from manager";
        break;
      case 924:
        p += "Cannot link from " + t[0] + " to " + this + " because no connection type can be adopted for this linkage";
        break;
      // // // 930 - 939: succeeded linking from source connective object
      case 930:
        p += "Successfully linked from " + t[0] + " to " + this + " via " + t[1] + "(registered with manager)";
        l = 3;
        r = true;
        break;
      case 931:
        p += "Successfully linked from " + t[0] + " to " + this + " via " + t[1];
        l = 3;
        r = true;
        break;
      // // 940 - 959: get a connecting object linked to target object
      // // // 940 - 949: failed getting a connecting object linked to target object
      case 940:
        p += "Cannot get a connecting object linked to " + t[0] + " from " + this + " because such a connecting object cannot be found";
        break;
      case 941:
        p += "Cannot get a connecting object linked to " + t[0] + " from " + this + " because " + t[0] + " cannot be linked from " + this;
        break;
      // // // 950 - 959: succeeded getting a connecting object linked to target object
      case 950:
        p += "Successfully obtained " + t[1] + " linked to " + t[0] + " from " + this;
        l = 3;
        r = true;
        break;
      // // 960 - 979: get a connecting object linked from source object
      // // // 960 - 969: failed getting a connecting object linked from source object
      case 960:
        p += "Cannot get a connecting object linked from " + t[0] + " to " + this + " because such a connecting object cannot be found";
        break;
      case 961:
        p += "Cannot get a connecting object linked from " + t[0] + " to " + this + " because " + t[0] + " cannot be linked from " + this;
        break;
      // // // 970 - 979: succeeded getting a connecting object linked to target object
      case 970:
        p += "Successfully obtained " + t[1] + " linked from " + t[0] + " to " + this;
        l = 3;
        r = true;
        break;
      // // 980 - 999: filter user against requirements
      // // // 980 - 989: failed filtering user against requirements
      case 980:
        p += "Cannot filter input users against " + this + "'s Requirement(s) because " + this + "'s Container is absent";
        break;
      case 981:
        p += "Cannot filter input users against " + this + "'s Requirement(s) because " + this + "'s Container " + t[0] + " cannot filter users";
        break;
      case 982:
        p += "Cannot filter input users against " + this + "'s Requirement(s) because " + this + "'s Container " + t[0] + " failed filtering users";
        break;
      case 983:
        p += "Cannot filter input users against " + this + "'s Requirement(s) because " + this + "'s parent is absent";
        break;
      case 984:
        p += "Cannot filter input users against " + this + "'s Requirement(s) because " + this + "'s parent Pool " + t[0] + " cannot filter users";
        break;
      case 985:
        p += "Cannot filter input users against " + this + "'s Requirement(s) because " + this + "'s parent Pool " + t[0] + " failed filtering users";
        break;
      // // // 990 - 999: succeeded filtering user against requirements
      case 990:
        p += "Successfully filtered input users against " + this + "'s Ability Requirement(s): " + t[0] + "/" + t[1] + " user(s) left ";
        l = 3;
        r = true;
        break;
      case 991:
        p += "Successfully filtered input users against " + this + "'s Network Requirement(s): " + t[0] + "/" + t[1] + " user(s) left ";
        l = 3;
        r = true;
        break;
      case 992:
        p += "Successfully filtered input users against " + this + "'s Position Requirement(s): " + t[0] + "/" + t[1] + " user(s) left ";
        l = 3;
        r = true;
        break;
      case 993:
        p += t[0] + " has been selected to remain in the candidate list because " + t[0] + " meets " + this + "'s " + t[1];
        l = 1;
        r = true;
        break;
      case 994:
        p += t[0] + " has been taken off from the candidate list because " + t[0] + " does not meet " + this + "'s " + t[1];
        l = 1;
        r = true;
        break;

      // 1000 - 1099: user feature
      // // 1000 - 1009: ability
      case 1000: // type
        p += "Cannot add " + t[0] + " as an Ability to " + this + " because " + t[0] + " is not an Ability";
        break;
      case 1001: // already has
        p += "Cannot add " + t[0] + " as an Ability to " + this + " because " + this + " already has " + t[0] + " as an Ability";
        break;
      case 1002: // type
        p += "Cannot remove " + t[0] + " as an Ability from " + this + " because " + t[0] + " is not an Ability";
        break;
      case 1003: // does not have
        p += "Cannot remove " + t[0] + " as an Ability from " + this + " because " + this + " does not have " + t[0] + " as an Ability";
        break;
      case 1008:
        p += "Successfully add " + t[0] + " as an Ability to " + this;
        l = 3;
        r = true;
        break;
      case 1009:
        p += "Successfully remove " + t[0] + " as an Ability from " + this;
        l = 3;
        r = true;
        break;
      // // 1010 - 1019: position
      case 1010: // type
        p += "Cannot add " + t[0] + " as a Position to " + this + " because " + t[0] + " is not a position";
        break;
      case 1011: // already has
        p += "Cannot add " + t[0] + " as a Position to " + this + " because " + this + " already has " + t[0] + " as a Position";
        break;
      case 1012: // type
        p += "Cannot remove " + t[0] + " as a Position from " + this + " because " + t[0] + " is not a Position";
        break;
      case 1013: // does not have
        p += "Cannot remove " + t[0] + " as a Position from " + this + " because " + this + " does not have " + t[0] + " as a Position";
        break;
      case 1018:
        p += "Successfully add " + t[0] + " as a Position to " + this;
        l = 3;
        r = true;
        break;
      case 1019:
        p += "Successfully remove " + t[0] + " as a Position from " + this;
        l = 3;
        r = true;
        break;
      // // 1020 - 1029: network
      case 1020: // type
        p += "Cannot add " + t[0] + " as a Network to " + this + " because " + t[0] + " is not a Network";
        break;
      case 1021: // already has
        p += "Cannot add " + t[0] + " as a Network to " + this + " because " + this + " already has " + t[0] + " as a Network";
        break;
      case 1022: // type
        p += "Cannot remove " + t[0] + " as a Network from " + this + " because " + t[0] + " is not a Network";
        break;
      case 1023: // does not have
        p += "Cannot remove " + t[0] + " as a Network from " + this + " because " + this + " does not have " + t[0] + " as a Network";
        break;
      case 1028:
        p += "Successfully add " + t[0] + " as a Network to " + this;
        l = 3;
        r = true;
        break;
      case 1029:
        p += "Successfully remove " + t[0] + " as a Network from " + this;
        l = 3;
        r = true;
        break;


      default:
        p += "FATAL ERROR: unknown state caused by ";
        int len = t.length;
        for(int i = 0; i < len; i++) {
          p += t[i];
          if(i < len - 1) {
            p += ", ";
          }
        }
        l = 10;
        break;
    }
    if(!mute) {
      System.out.println(p);
    }
    return r;
  }

  public abstract String getType();
}
